#pragma once

#ifndef _MY_MODEL_H_
#define _MY_MODEL_H_
#ifdef WIN32
#pragma execution_character_set("utf-8")
#endif

#include <qdebug.h>
#include <qobject.h>
#include <qdatetime.h>
#include <qstring.h>
#include <opencv2\opencv.hpp>
#include "idProducer.h"
#include "configuration.h"


/// <summary>
/// 数据库模型
/// </summary>
namespace MyModel {

	/// <summary>
	/// 保存采集到的图像数据，以及通过采集到的图像计算到的高度信息
	/// </summary>
	typedef struct _FrameData {

		int num;				//图像编号

		cv::Mat frame;			//图像数据

		vector<double> data;	//检测到的信息

		_FrameData(int _num, cv::Mat& _frame) : num(_num), frame(_frame.clone()) {
			_frame.release();
		}

		_FrameData(const _FrameData& other) {
			num = other.num;
			frame = other.frame;
			data = other.data;
		}


	} FrameData;

	typedef struct TestParam {

		//编号
		qint64 id;

		//班次名称
		QString name;

		//上次使用时间
		QDateTime lastUseTime;
		
		TestParam() : TestParam("") { };

		TestParam(QString name, QDateTime createTime = QDateTime::currentDateTime())
			: id(IdProducer::nextId()), name(name), lastUseTime(createTime) { };

	} TestParam;

	// 将TestParam分别取别名为牌号，检测员和班次
	typedef TestParam Brand;

	typedef TestParam Tester;

	typedef TestParam Schedule;


	/// <summary>
	/// 检测数据
	/// </summary>
	typedef struct TestData {

		//数据ID
		qint64 id;

		//检测记录
		qint64 recordId;

		//检测编号
		QString num;

		//添加时间
		QDateTime createTime;

	} TestData;


	/// <summary>
	/// 检测记录
	/// </summary>
	typedef struct TestRecord {

		//数据ID
		qint64 id;
		
		//检测员
		QString tester;
		
		//班次
		QString schedule;
		
		//牌号
		QString brand;
		
		//样本批次
		//QString batch;
		
		//添加时间
		QDateTime createTime;

		//检测数据
		QList<TestData> dataList;

		TestRecord(const QString& brand = "", const QString& tester = "", const QString& schedule = "")
			: id(IdProducer::nextId()), 
			brand(brand),
			tester(tester),
			schedule(schedule),
			createTime(QDateTime::currentDateTime()) { };

	} TestRecord;

}

#endif